function [y] = sum_boltzmann(x, p);
% sum_boltzman:
% calculate sum of multiple boltzman functions at specified X locations.
%
y=[];

if(nargin == 0)
   fprintf('sum_boltzman: \n');
   fprintf('call: sum_boltzman(x, [offset, amplitude, slope, vhalf, a2, s2, vh2, ...])\n');
   fprintf(' or with more amplitude, slope, vhalf values for sum of multiple functions\n');
   return;
end;
if(nargin > 2)
   fprintf('sum_boltzmann: call with (x, [array of parameters])\n');
   return;
end;

offset = p(1);
nb = 0;
for i = 2:3:length(p)
   nb = nb + 1;
   a(nb) = p(i);
   s(nb) = p(i+1);
   vh(nb) = p(i+2);
end;

% do computation

y=zeros(1, length(x));
for i = 1:nb % for all boltzman paramters.
   y = y + (a(i))./(1+exp(-(x-vh(i))*s(i)));
end;
y = y + offset;
return;
